﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using TeamService.ViewModal;
using System.Windows.Media.Animation;


namespace TeamService
{
    /// <summary>
    /// StartSplash.xaml 的交互逻辑
    /// </summary>
    public partial class StartSplash : Window
    {
        public StartSplash()
        {
            InitializeComponent();
        }

        public void Load(object sender,RoutedEventArgs e)
        {
            TeamServieceViewModal tvm = new TeamServieceViewModal();
#if DEBUG
            if (tvm.AuthorRight == null)
                tvm.AuthorRight = new AuthorRight();
            tvm.AuthorRight.Right = 2;
#endif
            Notice.Text = "正在读取数据";
            Task t = new Task(() =>
            {
                var code = tvm.Load();
                Dispatcher.Invoke(() =>
                {
                    if (code)
                    {
                        Notice.Text = "读取数据完成";
                        var s = new MainWindow(tvm);
                        s.Show();
                        this.Close();
                    }
                    else
                    {
                        Notice.Text = "连接服务器失败";
                    }
                });
            });
            t.Start();
        }
    }
}
